#@IgnoreInspection BashAddShebang
FROM ubuntu:focal
WORKDIR /code
COPY requirements.txt  /code
COPY requirements-install.txt /code
COPY scrapy.cfg /code
RUN sed -i "s/archive.ubuntu.com/mirrors.nju.edu.cn/g" /etc/apt/sources.list
RUN sed -i "s/security.ubuntu.com/mirrors.nju.edu.cn/g" /etc/apt/sources.list
RUN apt-get update -y && apt-get install -y python3 && rm -rf /var/lib/apt/lists/*
RUN apt-get update -y && apt-get install -y python3-pip && rm -rf /var/lib/apt/lists/*
RUN apt-get update -y && DEBIAN_FRONTEND="noninteractive" apt-get install -y python3-scrapy && rm -rf /var/lib/apt/lists/*
### maybe need to install python3-twisted
RUN pip install --no-cache-dir -r /code/requirements.txt -i https://pypi.douban.com/simple
RUN pip install --no-cache-dir -r /code/requirements-install.txt -i https://pypi.douban.com/simple
#RUN pip install --no-cache-dir pymongo==3.12.3 -i https://pypi.douban.com/simple
COPY . /code/

ENTRYPOINT ["scrapy"]
CMD ["crawl", "dmoz"]

#ENTRYPOINT ["python3","-m","http.server"]
